<template>
  <div>
    <div class="top11">
      <Form
        ref="formRef"
        name="advanced_search"
        class="ant-advanced-search-form"
        :model="formState"
        :label-col="labelCol"
        :wrapper-col="wrapperCol"
      >
        <Row :gutter="[16, 1]">
          <Col :span="6">
            <!-- v-on:input="onChange" -->
            <Form.Item>
              <a-input
                v-model:value="searchValue"
                autocomplete="off"
                allow-clear
                placeholder="000请输入您的搜索内容"
                :maxlength="30"
                @keyup.enter="onSearch"
                @change="onSearch"
              >
                <template #prefix
                  ><img src="@/assets/images/accommodation/jiaoxue_icon_sousuo.png" alt=""
                /></template>
              </a-input>
            </Form.Item>
          </Col>
          <Col :span="18">
            <div class="search">
              <div class="search-btn">
                <a-button
                  type="primary"
                  style="margin: 0 0 0 16px; display: flex; align-items: center"
                  ghost
                  @click="onClickCheckSetting"
                >
                  <template #icon><SettingOutlined /></template>
                  ioio考核设置
                </a-button>
              </div>
            </div>
          </Col>
        </Row>
      </Form>
    </div>
    <div class="below11">
      <div class="search">
        <div class="search-btn-left">
          <a-button type="primary" style="margin-right: 16px" @click="addClassify(1)"
            >新增分类</a-button
          >
          <a-button ghost style="margin-right: 16px" @click="addAssessment">新增考核项目</a-button>
        </div>
      </div>
      <div class="tree-content">
        <a-directory-tree
          v-model:expandedKeys="expandedKeys"
          v-model:selectedKeys="selectedKeys"
          :auto-expand-parent="autoExpandParent"
          :tree-data="treeData"
          @expand="onExpand"
        >
          <template v-slot:title="nodeData">
            <div class="arow">
              <div style="width: 500px; text-align: left">{{ nodeData.title }}</div>
              <div v-if="nodeData.markMode === 0" style="text-align: left">
                <span v-if="nodeData.markScore > 0">固定分&nbsp;+{{ nodeData.markScore }}分</span>
                <span v-else-if="nodeData.markScore !== 0"
                  >固定分&nbsp;{{ nodeData.markScore }}分</span
                >
              </div>
              <div v-else-if="nodeData.markMode === 1" style="text-align: left">手动分</div>
              <div>
                <a-button
                  size="small"
                  style="z-index: 1; border: 1px solid #56d6b7; color: #56d6b7; margin-right: 16px"
                  @click="edit(3, nodeData.key, nodeData.title, nodeData.itemType)"
                  @click.stop
                  >编辑</a-button
                >
                <a-button
                  v-if="nodeData.itemType === 0"
                  size="small"
                  style="z-index: 1; border: 1px solid #e4b778; color: #e4b778; margin-right: 16px"
                  @click="addClassify(2, nodeData.title, nodeData.key)"
                  @click.stop
                  >添加</a-button
                >
                <a-button
                  size="small"
                  style="z-index: 1; color: #999999"
                  @click="delRule(nodeData.key)"
                  @click.stop
                  >删除</a-button
                >
              </div>
            </div>
          </template>
        </a-directory-tree>
        <!-- 新加的开始 -->
        <!-- 添加 -->
        <Form
          ref="formRefs"
          name="dynamic_form_item"
          :model="dynamicValidateForm"
          v-bind="formItemLayoutWithOutLabel"
        >
          <div
            >亮灯时间：
            <a-time-picker
              v-model:value="settingLampTime.startTime"
              format="HH:mm:ss"
              @change="changeTimeStart"
            ></a-time-picker>
            <a-time-picker
              v-model:value="settingLampTime.stopTime"
              format="HH:mm:ss"
              @change="changeTimeStop"
            ></a-time-picker>
          </div>
          <Form.Item
            v-for="(domain, index) in dynamicValidateForm.manual"
            :key="index"
            v-bind="index === 0 ? formItemLayout : {}"
            :name="['domains', index, 'value']"
            :rules="{
              required: true,
              message: 'domain can not be null',
              trigger: 'change'
            }"
          >
            <div>
              <div style="width: 100%; margin-top: 16px; border: 1px solid #f00">
                <div
                  style="
                    width: 100%;
                    height: 56px;
                    background: #f8f8f8;
                    border-radius: 4px;
                    padding: 10px 6px;
                  "
                >
                  <Form ref="formRoomRef" name="advanced_search" class="ant-advanced-search-form">
                    <Row :gutter="[16, 1]">
                      <!-- <Col :span="2">
                        <Form.Item label="等级">
                          <a-input
                            v-model:value="domain.gradeName"
                            placeholder="请输入"
                            maxlength="5"
                          >
                          </a-input>
                        </Form.Item>
                      </Col> -->
                      <Col :span="7">
                        <Form.Item label="颜色">
                          <a-select
                            ref="select"
                            v-model:value="domain.lightColor"
                            placeholder="请选择"
                          >
                            <a-select-option :value="1">绿色</a-select-option>
                            <a-select-option :value="2">白色</a-select-option>
                            <a-select-option :value="3">红色</a-select-option>
                          </a-select>
                        </Form.Item>
                      </Col>
                      <Col :span="13">
                        <Form.Item label="宿舍评分在">
                          <Row :gutter="[4, 1]" class="line-z">
                            <Col :span="6">
                              <a-input
                                v-model:value="domain.rangeStart"
                                autocomplete="off"
                                placeholder="请输入"
                                @change="changLanpInput"
                              ></a-input>
                            </Col>
                            <Col :span="4" class="text-center">分到</Col>
                            <Col :span="6">
                              <a-input
                                v-model:value="domain.rangeStop"
                                autocomplete="off"
                                placeholder="请输入"
                                @change="changLanpInput"
                              ></a-input>
                            </Col>
                            <Col :span="8">分的宿舍</Col>
                          </Row>
                        </Form.Item>
                      </Col>
                      <!-- <Col :span="7">
                        <Form.Item label="分值范围">
                          <Row :gutter="[4, 1]">
                            <Col :span="5">
                              <a-select
                                ref="select"
                                v-model:value="domain.gradeScoreStartComputeType"
                              >
                                <a-select-option value="-">-</a-select-option>
                                <a-select-option value="+">+</a-select-option>
                              </a-select>
                            </Col>
                            <Col :span="6">
                              <a-input
                                v-model:value="domain.gradeScoreStart"
                                placeholder="请输入"
                              ></a-input>
                            </Col>
                            <Col :span="2"> —</Col>
                            <Col :span="5">
                              <a-select
                                ref="select"
                                v-model:value="domain.gradeScoreStopComputeType"
                              >
                                <a-select-option value="-">-</a-select-option>
                                <a-select-option value="+">+</a-select-option>
                              </a-select>
                            </Col>
                            <Col :span="6">
                              <a-input
                                v-model:value="domain.gradeScoreStop"
                                placeholder="请输入"
                              ></a-input>
                            </Col>
                          </Row>
                        </Form.Item>
                      </Col> -->
                      <Col :span="1">
                        <MinusCircleOutlined
                          v-if="dynamicValidateForm.manual.length > 1"
                          style="font-size: 20px; margin: 4px 3px 5px 5px; border: 1px solid blue"
                          class="dynamic-delete-button"
                          @click="removeDomainNew(domain, 4)"
                      /></Col>
                    </Row>
                  </Form>
                </div>
              </div>
            </div>
          </Form.Item>
          <div class="dialog-add" @click="addDomain(4)">
            <div class="week-content-add" style="margin-left: 0; width: 709px">
              <span>添加</span>
              <img src="@/assets/images/accommodation/u_plus.png" alt="" />
            </div>
          </div>
          <div class="search">
            <div class="search-btn-left">
              <a-button ghost style="margin-right: 16px"> 取消 </a-button>
              <!-- setFastMarkAPINew() -->
              <a-button
                type="primary"
                style="margin-right: 16px"
                @click="SaveLightSettingAndType()"
              >
                保存
              </a-button>
            </div>
          </div>
        </Form>
        <!-- 新加的结束 -->
      </div>
    </div>
    <!-- 考核设置 弹窗 -->
    <my-dialog
      :dialog-state="checkSetting.visible"
      :dialog-title="checkSetting.title"
      :btn-state="checkSetting.state"
      :disabled="checkSetting.dis"
      :dialog-width="checkSetting.width"
      :icon-type="checkSetting.iconType"
      @handleCancel="onCheckSettingCancel"
      @handleOk="onCheckSettingOK"
    >
      <template v-slot:location>
        <div>
          <a-tabs v-model:activeKey="checkSettingValue" @change="onChangeCheckSetting">
            <a-tab-pane v-for="item in nav" :key="item.dataIndex" :tab="item.title">
              <!-- 打分模式 -->
              <div v-if="item.dataIndex == '1'">
                <a-radio-group v-model:value="examineSetting.markModel">
                  <a-radio :value="0">考核项目打分</a-radio>
                  <a-radio :value="1">考核项目关联等级打分</a-radio>
                </a-radio-group>

                <div
                  v-if="examineSetting.markModel === 1"
                  style="
                    width: 705px;
                    border: 1px solid #e1dddd;
                    border-radius: 4px;
                    margin-top: 16px;
                  "
                >
                  <p style="color: #999999; font-size: 14px" class="tips"
                    >注: 输入的分值范围为左闭右开</p
                  >
                  <a-tabs v-model:activeKey="gradeRelationType">
                    <a-tab-pane
                      v-for="item2 in nav2"
                      :key="item2.dataIndex"
                      :tab="item2.title"
                      @click="btn"
                    >
                      <!-- 添加 -->
                      <Form
                        ref="formRefs"
                        name="dynamic_form_item"
                        :model="dynamicValidateForm"
                        v-bind="formItemLayoutWithOutLabel"
                      >
                        <div style="margin-top: 10px">
                          <div v-if="item2.dataIndex == '1'">
                            <Form.Item
                              v-for="(domain, index) in dynamicValidateForm.domains"
                              :key="domain.key"
                              v-bind="index === 0 ? formItemLayout : {}"
                              :name="['domains', index, 'value']"
                              :rules="{
                                required: true,
                                message: 'domain can not be null',
                                trigger: 'change'
                              }"
                            >
                              <!-- 关联项目条数 -->
                              <div
                                style="
                                  width: 657px;
                                  height: 56px;
                                  background: #f8f8f8;
                                  border-radius: 4px;
                                  margin-left: 24px;
                                  padding: 10px 6px;
                                "
                              >
                                <Form
                                  ref="formRoomRef"
                                  name="advanced_search"
                                  class="ant-advanced-search-form"
                                >
                                  <Row :gutter="[4, 1]">
                                    <Col :span="5">
                                      <Form.Item label="等级名称">
                                        <a-input
                                          v-model:value="domain.gradeName"
                                          autocomplete="off"
                                          placeholder="请输入"
                                          maxlength="5"
                                        >
                                        </a-input>
                                      </Form.Item>
                                    </Col>
                                    <Col :span="8">
                                      <Form.Item label="等级分值">
                                        <Row :gutter="[4, 1]">
                                          <Col :span="10">
                                            <a-select
                                              ref="select"
                                              v-model:value="domain.gradeScoreComputeType"
                                            >
                                              <a-select-option value="-">-</a-select-option>
                                              <a-select-option value="+">+</a-select-option>
                                            </a-select>
                                          </Col>
                                          <Col :span="14">
                                            <a-input
                                              v-model:value="domain.gradeScore"
                                              autocomplete="off"
                                              placeholder="请输入"
                                            ></a-input>
                                          </Col>
                                        </Row>
                                      </Form.Item>
                                    </Col>
                                    <Col :span="9">
                                      <Form.Item label="关联">
                                        <Row :gutter="[4, 1]">
                                          <Col :span="7">
                                            <a-select
                                              ref="select"
                                              v-model:value="domain.relationComputeType"
                                            >
                                              <a-select-option value=">">></a-select-option>
                                              <a-select-option value="=">=</a-select-option>
                                              <a-select-option value="<"> &lt; </a-select-option>
                                            </a-select>
                                          </Col>
                                          <Col :span="8">
                                            <a-input
                                              v-model:value="domain.relationItemNum"
                                              autocomplete="off"
                                              placeholder="请输入"
                                            ></a-input>
                                          </Col>
                                          <Col :span="9">
                                            <div style="margin: 5px auto">条考核项目</div>
                                          </Col>
                                        </Row>
                                      </Form.Item>
                                    </Col>
                                    <Col :span="1">
                                      <MinusCircleOutlined
                                        v-if="dynamicValidateForm.domains.length > 1"
                                        style="font-size: 20px; margin: 4px 3px 5px 5px"
                                        class="dynamic-delete-button"
                                        @click="removeDomain(domain, 1)"
                                    /></Col>
                                  </Row>
                                </Form>
                              </div>
                            </Form.Item>

                            <div class="dialog-add" @click="addDomain(1)">
                              <div class="week-content-add">
                                <span>添加</span>
                                <img src="@/assets/images/accommodation/u_plus.png" alt="" />
                              </div>
                            </div>
                          </div>

                          <div v-else>
                            <Form.Item
                              v-for="(item, index) in dynamicValidateForm.projectPoints"
                              :key="item.key"
                              v-bind="index === 0 ? formItemLayout : {}"
                              :name="['domains', index, 'value']"
                              :rules="{
                                required: true,
                                message: 'domain can not be null',
                                trigger: 'change'
                              }"
                            >
                              <!-- 关联项目分 -->
                              <div
                                style="
                                  width: 657px;
                                  height: 56px;
                                  background: #f8f8f8;
                                  border-radius: 4px;
                                  margin-left: 24px;
                                  padding: 10px 6px;
                                "
                              >
                                <Form
                                  ref="formRoomRef"
                                  name="advanced_search"
                                  class="ant-advanced-search-form"
                                >
                                  <Row :gutter="[16, 1]">
                                    <Col :span="7">
                                      <Form.Item label="等级名称">
                                        <a-input
                                          v-model:value="item.gradeName"
                                          autocomplete="off"
                                          placeholder="请输入"
                                          maxlength="5"
                                        >
                                        </a-input>
                                      </Form.Item>
                                    </Col>
                                    <Col :span="13">
                                      <Form.Item label="分值范围">
                                        <Row :gutter="[4, 1]">
                                          <Col :span="5">
                                            <a-select
                                              ref="select"
                                              v-model:value="item.gradeScoreStartComputeType"
                                            >
                                              <a-select-option value="-">-</a-select-option>
                                              <a-select-option value="+">+</a-select-option>
                                            </a-select>
                                          </Col>
                                          <Col :span="6">
                                            <a-input
                                              v-model:value="item.gradeScoreStart"
                                              autocomplete="off"
                                              :class="
                                                alive == item.key && place == '上' ? 'red' : ''
                                              "
                                              placeholder="请输入"
                                              @blur="animateWidth(item)"
                                            ></a-input>
                                          </Col>
                                          <Col :span="2"> —</Col>
                                          <Col :span="5">
                                            <a-select
                                              ref="select"
                                              v-model:value="item.gradeScoreStopComputeType"
                                            >
                                              <a-select-option value="-">-</a-select-option>
                                              <a-select-option value="+">+</a-select-option>
                                            </a-select>
                                          </Col>
                                          <Col :span="5">
                                            <a-input
                                              v-model:value="item.gradeScoreStop"
                                              autocomplete="off"
                                              :class="
                                                alive == item.key && place == '下' ? 'red' : ''
                                              "
                                              placeholder="请输入"
                                              @blur="animateWidth(item)"
                                            ></a-input>
                                          </Col>
                                          <Col :span="1">
                                            <MinusCircleOutlined
                                              v-if="dynamicValidateForm.projectPoints.length > 1"
                                              style="font-size: 20px; margin: 4px 3px 5px 5px"
                                              class="dynamic-delete-button"
                                              @click="removeDomain(item, 2)"
                                          /></Col>
                                        </Row>
                                      </Form.Item>
                                    </Col>
                                  </Row>
                                </Form>
                              </div>
                            </Form.Item>
                            <div class="dialog-add" @click="addDomain(2)">
                              <div class="week-content-add">
                                <span>添加</span>
                                <img src="@/assets/images/accommodation/u_plus.png" alt="" />
                              </div>
                            </div>
                          </div>
                        </div>
                      </Form>
                    </a-tab-pane>
                  </a-tabs>
                </div>
              </div>
              <!-- 快速打分 -->
              <div v-if="item.dataIndex == '2'">
                <span style="width: 80px; height: 24px; color: #666666; font-size: 16px"
                  >快速打分：</span
                >
                <a-switch
                  v-model:checked="examineSetting.isFastMark"
                  checked-children="关"
                  un-checked-children="启"
                  :checked-value="1"
                  :un-checked-value="0"
                />
                <br />
                <template v-if="examineSetting.isFastMark === 1">
                  <a-radio-group v-model:value="dynamicValidateForm.gradeType">
                    <a-radio :value="2" style="margin-top: 16px" @change="onCheck(2, $event)"
                      >固定分值</a-radio
                    >
                    <!-- 添加 -->
                    <Form
                      v-if="onScoreg"
                      ref="formRefs"
                      name="dynamic_form_item"
                      :model="dynamicValidateForm"
                      v-bind="formItemLayoutWithOutLabel"
                    >
                      <Form.Item
                        v-for="(domain, index) in dynamicValidateForm.fixed"
                        :key="index"
                        v-bind="index === 0 ? formItemLayout : {}"
                        :name="['domains', index, 'value']"
                        :rules="{
                          required: true,
                          message: 'domain can not be null',
                          trigger: 'change'
                        }"
                      >
                        <div>
                          <div style="width: 709px; margin-top: 16px">
                            <div
                              style="
                                width: 709px;
                                height: 56px;
                                background: #f8f8f8;
                                border-radius: 4px;
                                padding: 10px 6px;
                              "
                            >
                              <Form
                                ref="formRoomRef"
                                name="advanced_search"
                                class="ant-advanced-search-form"
                              >
                                <Row :gutter="[16, 1]">
                                  <Col :span="7">
                                    <Form.Item label="等级名称">
                                      <a-input
                                        v-model:value="domain.gradeName"
                                        autocomplete="off"
                                        placeholder="请输入"
                                        maxlength="5"
                                      >
                                      </a-input>
                                    </Form.Item>
                                  </Col>
                                  <Col :span="10">
                                    <Form.Item label="等级分值">
                                      <Row :gutter="[4, 1]">
                                        <Col :span="10">
                                          <a-select
                                            ref="select"
                                            v-model:value="domain.gradeScoreComputeType"
                                          >
                                            <a-select-option value="-">-</a-select-option>
                                            <a-select-option value="+">+</a-select-option>
                                          </a-select>
                                        </Col>
                                        <Col :span="13">
                                          <a-input
                                            v-model:value="domain.gradeScore"
                                            autocomplete="off"
                                            placeholder="请输入"
                                          ></a-input>
                                        </Col>
                                      </Row>
                                    </Form.Item>
                                  </Col>
                                  <Col :span="5">
                                    <MinusCircleOutlined
                                      v-if="dynamicValidateForm.fixed.length > 1"
                                      style="font-size: 20px; margin: 4px 3px 5px 5px"
                                      class="dynamic-delete-button"
                                      @click="removeDomain(domain, 3)"
                                  /></Col>
                                </Row>
                              </Form>
                            </div>
                          </div>
                        </div>
                      </Form.Item>
                      <div class="dialog-add" @click="addDomain(3)">
                        <div class="week-content-add" style="margin-left: 0; width: 709px">
                          <span>添加</span>
                          <img src="@/assets/images/accommodation/u_plus.png" alt="" />
                        </div>
                      </div>
                    </Form>
                    <div
                      style="
                        display: flex;
                        justify-content: space-between;
                        margin: 0px 37px 0px 0px;
                      "
                    >
                      <a-radio :value="3" @change="onCheck(3, $event)">手动打分 </a-radio>
                      <p style="color: #999999; font-size: 14px">注:输入的分值范围为左闭右开</p>
                    </div>

                    <!-- 添加 -->
                    <Form
                      v-if="onScores"
                      ref="formRefs"
                      name="dynamic_form_item"
                      :model="dynamicValidateForm"
                      v-bind="formItemLayoutWithOutLabel"
                    >
                      <Form.Item
                        v-for="(domain, index) in dynamicValidateForm.manual"
                        :key="index"
                        v-bind="index === 0 ? formItemLayout : {}"
                        :name="['domains', index, 'value']"
                        :rules="{
                          required: true,
                          message: 'domain can not be null',
                          trigger: 'change'
                        }"
                      >
                        <div>
                          <div style="width: 705px; margin-top: 16px">
                            <div
                              style="
                                width: 709px;
                                height: 56px;
                                background: #f8f8f8;
                                border-radius: 4px;
                                padding: 10px 6px;
                              "
                            >
                              <Form
                                ref="formRoomRef"
                                name="advanced_search"
                                class="ant-advanced-search-form"
                              >
                                <Row :gutter="[16, 1]">
                                  <Col :span="7">
                                    <Form.Item label="等级名称">
                                      <a-input
                                        v-model:value="domain.gradeName"
                                        autocomplete="off"
                                        placeholder="请输入"
                                        maxlength="5"
                                      >
                                      </a-input>
                                    </Form.Item>
                                  </Col>
                                  <Col :span="15">
                                    <Form.Item label="分值范围">
                                      <Row :gutter="[4, 1]">
                                        <Col :span="5">
                                          <a-select
                                            ref="select"
                                            v-model:value="domain.gradeScoreStartComputeType"
                                          >
                                            <a-select-option value="-">-</a-select-option>
                                            <a-select-option value="+">+</a-select-option>
                                          </a-select>
                                        </Col>
                                        <Col :span="6">
                                          <a-input
                                            v-model:value="domain.gradeScoreStart"
                                            autocomplete="off"
                                            placeholder="请输入"
                                          ></a-input>
                                        </Col>
                                        <Col :span="2"> —</Col>
                                        <Col :span="5">
                                          <a-select
                                            ref="select"
                                            v-model:value="domain.gradeScoreStopComputeType"
                                          >
                                            <a-select-option value="-">-</a-select-option>
                                            <a-select-option value="+">+</a-select-option>
                                          </a-select>
                                        </Col>
                                        <Col :span="6">
                                          <a-input
                                            v-model:value="domain.gradeScoreStop"
                                            autocomplete="off"
                                            placeholder="请输入"
                                          ></a-input>
                                        </Col>
                                      </Row>
                                    </Form.Item>
                                  </Col>
                                  <Col :span="1">
                                    <MinusCircleOutlined
                                      v-if="dynamicValidateForm.manual.length > 1"
                                      style="font-size: 20px; margin: 4px 3px 5px 5px"
                                      class="dynamic-delete-button"
                                      @click="removeDomain(domain, 4)"
                                  /></Col>
                                </Row>
                              </Form>
                            </div>
                          </div>
                        </div>
                      </Form.Item>
                      <div class="dialog-add" @click="addDomain(4)">
                        <div class="week-content-add" style="margin-left: 0; width: 709px">
                          <span>添加</span>
                          <img src="@/assets/images/accommodation/u_plus.png" alt="" />
                        </div>
                      </div>
                    </Form>
                  </a-radio-group>
                </template>
              </div>
              <!-- 其他 -->
              <div v-if="item.dataIndex == '3'">
                <p style="font-size: 16px; font-weight: 400; color: #666666"
                  >个人项目扣分汇总方式：</p
                >
                <a-radio-group v-model:value="examineSetting.summaryMethod">
                  <div style="width: 705px; margin-top: 16px">
                    <div
                      style="
                        width: 657px;
                        height: 56px;
                        background: #f8f8f8;
                        border-radius: 4px;
                        padding: 16px;
                        display: flex;
                        justify-content: space-between;
                      "
                    >
                      <a-radio :value="0">按个人扣分汇总</a-radio>
                      <Popover
                        :get-popup-container="
                          triggerNode => {
                            return triggerNode.parentNode || document.body;
                          }
                        "
                        trigger="hover"
                        placement="bottom"
                        :overlay-style="{
                          width: '250px',
                          height: 'auto'
                        }"
                      >
                        <template #content>
                          <p
                            >开启后：个人项目扣分汇总到宿舍集体时，按照每个人的扣分进行合计汇总，如：A宿舍有3人被褥未叠（个人项目-1），每个人
                            -1 分，汇总到宿舍集体为 -3 分。</p
                          >
                        </template>
                        <img
                          v-if="examineSetting.summaryMethod === 0"
                          src="@/assets/images/accommodation/fi_help-circle-color.png"
                          alt=""
                        />
                        <img v-else src="@/assets/images/accommodation/fi_help-circle.png" alt="" />
                      </Popover>
                    </div>
                  </div>
                  <div style="width: 705px; margin-top: 16px">
                    <div
                      style="
                        width: 657px;
                        height: 56px;
                        background: #f8f8f8;
                        border-radius: 4px;
                        padding: 16px;
                        display: flex;
                        justify-content: space-between;
                      "
                    >
                      <a-radio :value="1">按项扣分汇总</a-radio>
                      <Popover
                        :get-popup-container="
                          triggerNode => {
                            return triggerNode.parentNode || document.body;
                          }
                        "
                        placement="bottom"
                        :overlay-style="{
                          width: '250px',
                          height: 'auto'
                        }"
                      >
                        <template #content>
                          <p>
                            开启后：个人项目扣分汇总到宿舍集体分时，按照违反的项目分汇总，如：A宿舍有3个人被褥未叠（个人项目-1），每个人
                            -1 分，汇总到宿舍集体为 -1 分。</p
                          >
                        </template>
                        <img
                          v-if="examineSetting.summaryMethod === 1"
                          src="@/assets/images/accommodation/fi_help-circle-color.png"
                          alt=""
                        />
                        <img v-else src="@/assets/images/accommodation/fi_help-circle.png" alt="" />
                      </Popover>
                    </div>
                  </div>
                </a-radio-group>
              </div>
            </a-tab-pane>
          </a-tabs>
        </div>
      </template>
    </my-dialog>
    <!-- 新增 -->
    <my-dialog
      :dialog-state="newClassify.visible"
      :dialog-title="newClassify.title"
      :btn-state="newClassify.state"
      :disabled="newClassify.dis"
      :dialog-width="newClassify.width"
      :icon-type="newClassify.iconType"
      @handleCancel="addClassifyCancel"
      @handleOk="addClassifyOk()"
    >
      <template v-slot:location>
        <Form
          ref="formNew"
          name="advanced_search"
          class="ant-advanced-search-form"
          :model="formNewClassify"
          :label-col="labelColNewClassify"
          :wrapper-col="wrapperCol"
        >
          <Form.Item
            v-if="formNewClassify.idState == 2"
            :class="formNewClassify.idState == 2 ? 'required-tips' : ''"
            name="name"
            label="上级分类"
          >
            <a-input
              v-model:value="formNewClassify.Name"
              autocomplete="off"
              placeholder="请输入"
              disabled
            ></a-input>
          </Form.Item>
          <Form.Item name="name" class="required-tips" label="分类名称">
            <a-input
              v-model:value="formNewClassify.itemName"
              autocomplete="off"
              maxlength="10"
              placeholder="请输入"
            ></a-input>
          </Form.Item>
        </Form>
      </template>
    </my-dialog>
    <!-- 新增考核项目 弹窗 -->
    <my-dialog
      :dialog-state="newItems.visible"
      :dialog-title="newItems.title"
      :disabled="newItems.dis"
      :btn-state="newItems.state"
      :dialog-width="newItems.width"
      :icon-type="newItems.iconType"
      @handleCancel="newItems.visible = false"
      @handleOk="addAssessOK"
    >
      <template v-slot:location>
        <Form
          ref="formNew"
          name="advanced_search"
          class="ant-advanced-search-form"
          :model="formNewItems"
          :label-col="labelCol"
          :wrapper-col="wrapperCol"
        >
          <Form.Item name="name" label="考核项目名称" class="required-tips">
            <a-input
              v-model:value="formNewItems.itemName"
              autocomplete="off"
              :maxlength="30"
              placeholder="请输入"
            ></a-input>
          </Form.Item>

          <Form.Item label="所属分类" class="required-tip">
            <a-cascader
              v-model:value="aName"
              :options="optionList.AllSortExamineList"
              placeholder="请选择"
              @change="onNewItemsChange"
            />
          </Form.Item>

          <Form.Item label="扣分模式" class="required-tip">
            <a-select ref="select" v-model:value="formNewItems.markMode">
              <a-select-option :value="0">固定分</a-select-option>
              <a-select-option :value="1">手动分</a-select-option>
            </a-select>
          </Form.Item>
          <Form.Item v-if="formNewItems.markMode == 0" style="margin-left: 115px">
            <Row :gutter="[10, 1]">
              <Col :span="10">
                <a-select ref="select" v-model:value="formNewItems.addCut">
                  <a-select-option :value="1">-</a-select-option>
                  <a-select-option :value="2">+</a-select-option>
                </a-select>
              </Col>
              <Col :span="12">
                <a-input
                  v-model:value="formNewItems.markScore"
                  autocomplete="off"
                  placeholder="请输入"
                ></a-input>
              </Col>
              <Col :span="2"> 分 </Col>
            </Row>
          </Form.Item>
          <Form.Item label="考核对象" class="required-tip">
            <a-radio-group v-model:value="formNewItems.examineTarget">
              <a-radio :value="0">个人项目</a-radio>
              <a-radio :value="1">公共项目</a-radio>
            </a-radio-group>
          </Form.Item>
          <Form.Item v-if="formNewItems.markMode === '2'" label="关联值日生考核">
            <a-switch
              v-model:checked="formNewItems.isDuty"
              checked-children="关"
              un-checked-children="启"
            />
          </Form.Item>
        </Form>
      </template>
    </my-dialog>
    <!-- 删除 提示框 -->
    <my-dialog
      :dialog-state="del.visible"
      :dialog-title="del.title"
      :dialog-width="del.width"
      :icon-type="del.iconType"
      @handleCancel="del.visible = false"
      @handleOk="onDelete"
    >
      <template v-slot:location>
        <div class="checkOutStyle">
          <img src="@/assets/images/accommodation/drawable-xxxhdpi_popu_icon_warn.png" alt="" />
          <span>是否确认删除该规则？</span>
        </div>
        <span
          style="
            font-size: 12px;
            font-family: Source Han Sans CN, Source Han Sans CN-Regular;
            font-weight: 400;
            color: #999999;
          "
          >删除后本分类的历史打分数据将同步删除，请谨慎操作。</span
        >
      </template>
    </my-dialog>
  </div>
</template>
<script setup>
import dayjs from 'dayjs';
import { onMounted, reactive, ref, watch } from 'vue';
import { SettingOutlined, MinusCircleOutlined } from '@ant-design/icons-vue';
import { Form, Row, Col, Popover, message } from 'ant-design-vue';
import MyDialog from '@/components/dialog/index.vue';
import {
  getExamineItemTree,
  createOneExamineItem,
  createNextExamineItem,
  updateExamineItem,
  removeExamineItem,
  getAllSortExamineItem,
  getExamineItem,
  getExamineSetting,
  summarySetting,
  getExamineGradeDetail,
  setMarkModel,
  setFastMark,
  closeFastMark,
  getIdExamineItem,
  saveLightSettingAndType,
  getLightSetting,
  listLightType,
  removeLightType
} from '@/api/ruleSetting';
// saveLightSettingAndType 是亮灯的时间的设置
// getLightSetting 查询当前租户亮灯时间设置
// listLightType 查询当前租户所有亮灯规则
// removeLightType 根据ID删除亮灯规则
// js新加的开始
const changeTimeStart = (time, timeString) => {
  console.log('选择的时间是什么', time);
  console.log('选择的时间是什么', timeString);
  settingLampTimeNew.value.startTime = timeString;
};
const changeTimeStop = (time, timeString) => {
  console.log('选择的时间是什么', time);
  console.log('选择的时间是什么', timeString);
  settingLampTimeNew.value.stopTime = timeString;
};
const time_to_sec = time => {
  if (time !== null) {
    let s = '';
    let hour = time.split(':')[0];
    let min = time.split(':')[1];
    let sec = time.split(':')[2];
    s = Number(hour * 3600) + Number(min * 60) + Number(sec);
    return s;
  }
};
const timeRange = ref([]);
const settingLampTime = ref({
  startTime: '',
  stopTime: ''
});
const settingLampTimeNew = ref({
  startTime: '',
  stopTime: ''
});
// js新加的结束
const list = ref([]);
const alive = ref('');
const place = ref('');
const formRefs = ref();
const formItemLayout = {
  labelCol: {
    xs: {
      span: 24
    },
    sm: {
      span: 4
    }
  },
  wrapperCol: {
    xs: {
      span: 24
    },
    sm: {
      span: 20
    }
  }
};
const formItemLayoutWithOutLabel = {
  wrapperCol: {
    xs: {
      span: 24,
      offset: 0
    },
    sm: {
      span: 20,
      offset: 4
    }
  }
};

let onScoreg = ref(false);
let onScores = ref(false);

function onCheck(id, e) {
  if (e.target.checked) {
    if (id === 2) {
      onScoreg.value = true;
      onScores.value = false;
    } else if (id === 3) {
      onScoreg.value = false;
      onScores.value = true;
    }
  }
}
const btn = () => {
  list.value = [];
};

const addDomain = id => {
  if (id === 1) {
    dynamicValidateForm.value.domains.push({
      gradeName: '',
      key: Date.now()
    });
  } else if (id === 2) {
    if (list.value.length !== 0) {
      const name =
        dynamicValidateForm.value.projectPoints[dynamicValidateForm.value.projectPoints.length - 1]
          .gradeName;
      if (checkSetting.dis === false && name !== '') {
        dynamicValidateForm.value.projectPoints.push({
          gradeName: '',
          key: Date.now()
        });
      } else {
        if (name === '') {
          message.error('请输入等级名称');
        }
      }
    }
    // else {
    //   dynamicValidateForm.value.projectPoints.push({
    //     gradeName: '',
    //     key: Date.now()
    //   });
    // }
  } else if (id === 3) {
    dynamicValidateForm.value.fixed.push({
      gradeName: '',
      key: Date.now()
    });
  } else if (id === 4) {
    dynamicValidateForm.value.manual.push({
      gradeName: '',
      key: Date.now()
    });
  }
};

const Start = ref();
const Stop = ref();
const elStart = ref();
const elStop = ref();
const animateWidth = item => {
  if (item.gradeScoreStartComputeType === '-') {
    Start.value = -item.gradeScoreStart;
  } else {
    Start.value = item.gradeScoreStart;
  }
  if (item.gradeScoreStopComputeType === '-') {
    Stop.value = -item.gradeScoreStop;
  } else {
    Stop.value = item.gradeScoreStop;
  }

  if (Start.value && item.gradeScoreStop) {
    list.value = list.value.filter(function (val) {
      return val.key !== item.key;
    });

    list.value.forEach(element => {
      if (element.gradeName !== item.gradeName) {
        if (element.gradeScoreStartComputeType === '-') {
          elStart.value = -element.gradeScoreStart;
        } else {
          elStart.value = element.gradeScoreStart;
        }
        if (element.gradeScoreStopComputeType === '-') {
          elStop.value = -element.gradeScoreStop;
        } else {
          elStop.value = element.gradeScoreStop;
        }
        if (
          Number(Start.value) > Number(elStart.value) &&
          Number(Start.value) < Number(elStop.value)
        ) {
          console.log(Start.value, elStart.value, elStop.value, 'shang');

          place.value = '上';
          alive.value = item.key;
          checkSetting.dis = true;
          throw new Error();

          // return;
        } else if (
          Number(Stop.value) > Number(elStart.value) &&
          Number(Stop.value) < Number(elStop.value)
        ) {
          console.log(Start.value, elStart.value, elStop.value, 'xia');
          alive.value = item.key;
          place.value = '下';

          checkSetting.dis = true;
          // return;
          throw new Error();
        } else if (
          Number(Start.value) < Number(elStart.value) &&
          Number(Stop.value) > Number(elStop.value)
        ) {
          alive.value = item.key;
          place.value = '下';

          checkSetting.dis = true;
          // return;
          throw new Error();
        } else {
          alive.value = '';
          place.value = '';
          checkSetting.dis = false;
        }
      } else {
        alive.value = '';
        place.value = '';
        checkSetting.dis = false;
      }
    });

    list.value.push(item);
  }
};

const last = ref({});
const removeDomain = (item, id) => {
  if (id === 1) {
    let index = dynamicValidateForm.value.domains.indexOf(item);
    if (index !== -1) {
      dynamicValidateForm.value.domains.splice(index, 1);
    }
  } else if (id === 2) {
    list.value.forEach((element, index) => {
      if (element.key === item.key) {
        list.value.splice(index, 1);
        // last.value = list.value(list.value.length - 1);
        return;
      }
    });
    let index = dynamicValidateForm.value.projectPoints.indexOf(item);
    if (index !== -1) {
      dynamicValidateForm.value.projectPoints.splice(index, 1);
      if (checkSetting.dis === true) {
        // checkSetting.dis = false;
        // console.log(list.value[list.value.length - 1]);
        animateWidth(list.value[list.value.length - 1]);
      }
    }
  } else if (id === 3) {
    let index = dynamicValidateForm.value.fixed.indexOf(item);
    if (index !== -1) {
      dynamicValidateForm.value.fixed.splice(index, 1);
    }
  } else if (id === 4) {
    console.log('删除方法', item);
    let index = dynamicValidateForm.value.manual.indexOf(item);
    if (index !== -1) {
      dynamicValidateForm.value.manual.splice(index, 1);
    }
  }
};
// 新加的删除方法
const removeDomainNew = (item, id) => {
  console.log('删除方法', item.id);
  // 有id 执行删除接口  没有直接删除数组
  if (item.id && item.id !== undefined && item.id !== null) {
    removeLightType(item.id).then(res => {
      if (res.data.code === 200) {
        message.success(res.data.msg);
        console.log('删除方法结果', res.data.data);
        ListLightType();
      }
    });
  } else {
    let index = dynamicValidateForm.value.manual.indexOf(item);
    if (index !== -1) {
      dynamicValidateForm.value.manual.splice(index, 1);
    }
  }
};
const formRoomRef = ref();

// 树形控件
const expandedKeys = ref([]);
const selectedKeys = ref([]);
const treeData = ref([]);
// 异步加载时用
// const onLoadData = treeNode => {
//   return new Promise(resolve => {
//     if (treeNode.dataRef.children) {
//       resolve();
//       return;
//     }
//     setTimeout(() => {
//       treeNode.dataRef.children = [];
//       treeData.value = [...treeData.value];
//       resolve();
//     }, 1000);
//   });
// };

let submit = ref('0');
onMounted(() => {
  getClassifyList();
  getAllSortExamine();
  // if (dynamicValidateForm.value.projectPoints.gradeList[0].gradeName !== '') {

  // }
  // /////////////////////////////////
  // getExamineGrade();
  // 回显亮灯时间
  GetLightSetting();
  // 回显亮灯规则
  ListLightType();
});
// 获取分类列表
const getClassifyList = () => {
  getExamineItemTree().then(res => {
    if (res.data.code === 200) {
      treeData.value = [];
      res.data.data.forEach((item, index) => {
        treeData.value.push(getTreeNode(item, index));
      });
    }
  });
};
// 获取分类信息
const getAllSortExamine = () => {
  optionList.value.AllSortExamineList = [];
  getAllSortExamineItem().then(res => {
    if (res.data.code === 200) {
      res.data.data.forEach((item, index) => {
        optionList.value.AllSortExamineList.push(getSortExamine(item, index));
      });
    }
  });
};
function getSortExamine(item, index) {
  let childrenNode = {
    value: item.id,
    label: item.itemName,
    key: item.id
  };
  if (item.childList && item.childList.length) {
    childrenNode.children = [];
    item.childList.forEach((subItem, subIndex) => {
      let subkey = subItem.id;
      childrenNode.children.push(getSortExamine(subItem, subkey));
    });
  }
  return childrenNode;
}
function onNewItemsChange(key, selectedOptions) {
  // console.log(selectedOptions, 'selectedOptions111');
  formNewItems.value.ancestorId = '';
  selectedOptions.forEach(item => {
    formNewItems.value.ancestorId += item.key + ',';
  });
  formNewItems.value.ancestorId = formNewItems.value.ancestorId.substring(
    0,
    formNewItems.value.ancestorId.length - 1
  );
  formNewItems.value.superiorId = selectedOptions[selectedOptions.length - 1].key;
}

// 下拉选项列表
const optionList = ref({
  AllSortExamineList: []
});
function getTreeNode(item, index) {
  let markMode = ref(3);
  let markScore = ref(0);
  if (item.markMode !== 'undefined') {
    markMode.value = item.markMode;
    markScore.value = item.markScore;
  }
  let childrenNode = {
    title: item.itemName,
    key: item.id,
    markMode: markMode.value,
    markScore: markScore.value,
    itemType: item.itemType
  };
  if (item.childList && item.childList.length) {
    childrenNode.children = [];
    item.childList.forEach((subItem, subIndex) => {
      let subkey = subItem.id;
      childrenNode.children.push(getTreeNode(subItem, subkey));
    });
  }
  return childrenNode;
}
// label样式
const labelColNewClassify = reactive({
  xs: { span: 4 },
  sm: { span: 6 }
});
const labelCol = reactive({
  xs: { span: 4 },
  sm: { span: 8 }
});
const wrapperCol = reactive({
  xs: { span: 24 },
  sm: { span: 16 }
});
const formState = reactive({
  search: '' // 搜索内容
});
const formNewClassify = ref({
  superiorId: '', // 上级id
  idState: '',
  Name: '', // 上级分类名称
  itemName: '' // 分类名称
});
const nav = reactive([
  {
    title: '打分模式',
    dataIndex: '1',
    data: []
  },
  {
    title: '快速打分',
    dataIndex: '2',
    data: []
  },
  {
    title: '其他',
    dataIndex: '3',
    data: []
  }
]);
const nav2 = ref([
  {
    title: '关联项目条数',
    dataIndex: '1',
    data: []
  },
  {
    title: '关联项目分',
    dataIndex: '2',
    data: []
  }
]);
// 新增分类
const newClassify = reactive({
  title: '新增分类',
  visible: false,
  width: '388px',
  dis: true,
  iconType: 'default',
  state: '保存'
});

const formNewItems = ref({
  itemName: '', // 考核项目名称
  superiorId: '', // 所属分类
  markMode: 0, // 扣分模式
  addCut: '1', // 加减符号
  markScore: '', // 加减分数
  examineTarget: 0, // 考核对象
  isDuty: 'false', // 是否关联值日生考核
  name: [], // 所属分类
  ancestorId: ''
});
const aName = ref([]);
watch(
  () => formNewClassify.value.itemName,
  val => {
    if (val !== '') {
      newClassify.dis = false;
    } else {
      newClassify.dis = true;
    }
  }
);

// 新增考核项目
const newItems = reactive({
  title: '新增考核项目',
  visible: false,
  dis: true,
  width: '388px',
  iconType: 'default',
  state: '保存'
});
watch(
  () => aName.value,
  val => {
    console.log(formNewItems.value.itemName);
    if (val === undefined || (val.length === 0 && formNewItems.value.itemName === '')) {
      newItems.dis = true;
    } else {
      newItems.dis = false;
    }
  }
);

// 点击新增考核项目
function addAssessment() {
  newItems.title = '新增考核项目';
  ClassifyId.value = null;
  newItems.visible = true;
  getAllSortExamine();
  aName.value = [];
  formNewItems.value = {
    itemName: '', // 考核项目名称
    superiorId: '', // 所属分类
    markMode: 1, // 扣分模式
    addCut: 1, // 加减符号
    markScore: '', // 加减分数
    examineTarget: 0, // 考核对象
    isDuty: 'false', // 是否关联值日生考核
    name: '' // 所属分类
  };
  // formNewItems.value
}

// 新增考核项目
const addAssessOK = value => {
  if (addAssessForm()) {
    if (!ClassifyId.value) {
      // 添加子级分类
      if (formNewItems.value.markMode === 0) {
        if (formNewItems.value.addCut === 1) {
          formNewItems.value.markScore = '-' + formNewItems.value.markScore;
        }
      } else {
        formNewItems.value.markScore = '';
      }
      if (formNewItems.value.isDuty) {
        formNewItems.value.isDuty = 1;
      } else {
        formNewItems.value.isDuty = 0;
      }
      formNewItems.value.itemType = 1; // 项目类型(0分类 1 项目)
      formNewItems.value.itemName = formNewItems.value.itemName.replace(/,/gi, '，');
      createNextExamineItem(formNewItems.value).then(res => {
        if (res.data.code === 200) {
          message.success(res.data.msg);
        } else {
          message.error(res.data.msg);
        }
        onCancelNewRule();
        getClassifyList();
      });
      newItems.visible = false;
    } else {
      if (formNewItems.value.markMode === 0) {
        if (formNewItems.value.addCut === 1) {
          formNewItems.value.markScore = '-' + formNewItems.value.markScore;
        }
      } else {
        formNewItems.value.markScore = '';
      }
      formNewItems.value.itemName = formNewItems.value.itemName.replace(/,/gi, '，');
      console.log('formNewItems.value', formNewItems.value);
      updateExamineItem(formNewItems.value).then(res => {
        if (res.data.code === 200) {
          message.success(res.data.msg);
        } else {
          message.error(res.data.msg);
        }
        onCancelRule();
        getClassifyList();
      });
      newItems.visible = false;
    }
  }
};
// 搜索
function onSearch() {
  if (searchValue.value !== '') {
    let obj = {
      name: searchValue.value
    };
    getExamineItem(obj).then(res => {
      if (res.data.code === 200) {
        treeData.value = [];
        res.data.data.forEach((item, index) => {
          treeData.value.push(getTreeNode(item, index));
        });
      }
    });
  } else {
    getClassifyList();
    getAllSortExamine();
  }
}

// 清空form表单
const onCancelNewRule = () => {
  formNewItems.value = {
    itemName: '', // 考核项目名称
    superiorId: '', // 所属分类
    markMode: 1, // 扣分模式
    addCut: '-', // 加减符号
    markScore: '', // 加减分数
    examineTarget: 0, // 考核对象
    isDuty: 'false', // 是否关联值日生考核
    name: '' // 所属分类
  };
  newItems.visible = false;
};
// 验证新增考核项目表单
const addAssessForm = () => {
  if (!formNewItems.value.itemName) {
    message.error('请输入考核名称');
    return false;
  }
  if (!formNewItems.value.superiorId) {
    message.error('请选择所属分类');
    return false;
  }
  if (formNewItems.value.markMode === '') {
    message.error('请选择扣分模式');
    return false;
  }
  if (formNewItems.value.markMode === '0') {
    if (!formNewItems.value.markScore) {
      message.error('请输入分数');
      return false;
    }
  }

  if (formNewItems.value.examineTarget === '') {
    message.error('请选择考核对象');
    return false;
  }
  return true;
};

const ExamineItem = ref([]);
// 编辑分类
function edit(type, superiorId, title, itemType) {
  console.log(type, superiorId, title, itemType, 'type, superiorId, title, itemType');
  ClassifyId.value = null;
  // itemType   0分类 1 项目
  if (itemType === 0) {
    // 修改
    newClassify.title = '编辑';
    newClassify.visible = true;
    formNewClassify.value.idState = 1;
    submit.value = 3;
    formNewClassify.value.itemName = title;
    ClassifyId.value = superiorId;
  } else if (itemType === 1) {
    newItems.title = '修改考核项目';
    newItems.visible = true;

    getIdExamineItem(superiorId).then(res => {
      aName.value = [];
      if (res.data.code === 200) {
        formNewItems.value = res.data.data;
        if (res.data.data.markScore > 0) {
          formNewItems.value.addCut = 2;
        } else {
          formNewItems.value.addCut = 1;
          formNewItems.value.markScore = Math.abs(formNewItems.value.markScore);
        }
        const ancestor = res.data.data.ancestorId.split(',');
        for (let i = 0; i <= ancestor.length - 1; i++) {
          aName.value.push(ancestor[i]);
        }
        console.log(aName, 'aName');
      }
    });
    ClassifyId.value = superiorId;
    // onCancelNewRule();
    formNewItems.value = {
      itemName: '', // 考核项目名称
      superiorId: '', // 所属分类
      markMode: '1', // 扣分模式
      addCut: '-', // 加减符号
      markScore: '', // 加减分数
      examineTarget: '', // 考核对象
      isDuty: 'false', // 是否关联值日生考核
      name: '' // 所属分类
    };
  }
}

// 添加
function addClassify(type, title, superiorId) {
  ClassifyId.value = null;
  if (type === 1) {
    newClassify.visible = true;
    newClassify.title = '新增';
    submit.value = 1;
  } else if (type === 2) {
    formNewClassify.value.idState = 2;
    newClassify.title = '新增下级分类';
    newClassify.visible = true;
    submit.value = 2;
    formNewClassify.value.Name = title;
    formNewClassify.value.superiorId = superiorId;
  }
}
// 验证表单
const verificationForm = () => {
  if (!formNewClassify.value.itemName) {
    message.error('请输入分类名称');
    return false;
  }
  return true;
};
let ClassifyId = ref([]);
// 添加一级分类
const addClassifyOk = value => {
  if (verificationForm()) {
    if (!ClassifyId.value) {
      if (submit.value === 1) {
        // 添加一级分类
        createOneExamineItem(formNewClassify.value).then(res => {
          if (res.data.code === 200) {
            message.success(res.data.msg);
          } else {
            message.error(res.data.msg);
          }
          onCancelRule();
          getClassifyList();
        });
        newClassify.visible = false;
      } else if (submit.value === 2) {
        // 添加子级分类
        createNextExamineItem(formNewClassify.value).then(res => {
          if (res.data.code === 200) {
            message.success(res.data.msg);
          } else {
            message.error(res.data.msg);
          }
          onCancelRule();
          getClassifyList();
        });
        newClassify.visible = false;
      }
    } else {
      if (submit.value === 3) {
        // 修改分类名称
        let obj = {
          id: ClassifyId.value,
          itemName: formNewClassify.value.itemName
        };
        updateExamineItem(obj).then(res => {
          if (res.data.code === 200) {
            message.success(res.data.msg);
          } else {
            message.error(res.data.msg);
          }
          onCancelRule();
          getClassifyList();
        });
      }
    }
  }
};
// 取消
function addClassifyCancel() {
  onCancelRule();
}

// 清空form表单
const onCancelRule = () => {
  formNewClassify.value = {
    idState: '',
    Name: '', // 上级分类名称
    itemName: '' // 分类名称
  };
  newClassify.visible = false;
};

// 删除
const del = ref({
  title: '温馨提示',
  visible: false,
  width: '328px',
  iconType: 'default'
});

// 删除 事件
function delRule(id) {
  del.value.visible = true;
  del.value.state = true;
  del.value.id = id;
}

// 删除宿舍楼列表
const onDelete = () => {
  if (del.value.state) {
    removeExamineItem(del.value).then(res => {
      if (res.data.code === 200) {
        message.success(res.data.msg);
        del.value.visible = false;
        getClassifyList();
      } else {
        message.error(res.data.msg);
        del.value.state = false;
      }
    });
  } else {
    del.value.visible = false;
  }
};
const searchValue = ref('');
const autoExpandParent = ref(true);

const onExpand = keys => {
  expandedKeys.value = keys;
  autoExpandParent.value = false;
};

/** ***** tabs标签 ******* */
// tabs标签值
const checkSettingValue = ref('1');
// 切换回调
const onChangeCheckSetting = value => {
  console.log(value);
  if (Number(value) === 1) {
    getExamine();
  } else if (Number(value) === 2) {
    getExamineGrade();
  } else if (Number(value) === 3) {
    getExamine();
  }
};
/** ***** 考核设置 ******* */
// 考核设置弹窗
const checkSetting = reactive({
  title: '考核设置',
  visible: false,
  dis: false,
  width: '753px',
  iconType: 'default',
  state: '保存'
});

// 考核设置弹窗按钮
const onClickCheckSetting = () => {
  checkSetting.visible = true;
  // 设置个人项目扣分汇总方式
  if (checkSettingValue.value === '3') {
    getExamine();
  } else if (checkSettingValue.value === '1') {
    getExamine(); // 设置打分模式
  } else if (checkSettingValue.value === '2') {
    // 设置快速打分
    getExamineGrade();
  }
};
// 考核设置取消
const onCheckSettingCancel = () => {
  resetFormData();
  checkSetting.visible = false;
  checkSetting.dis = false;
  list.value = [];
};
// 考核设置保存
const onCheckSettingOK = () => {
  console.log(checkSettingValue.value, 'checkSettingValue.value');
  // 设置个人项目扣分汇总方式
  if (checkSettingValue.value === '3') {
    summarySet();
  } else if (checkSettingValue.value === '1') {
    setMarkModelAPI(); // 设置打分模式
  } else if (checkSettingValue.value === '2') {
    // 设置快速打分
    setFastMarkAPI();
  }
};
// 考核设置组装数据
const examineSetting = ref({
  markModel: 0, // 打分模式;0 考核项目打分 1 考核项目关联等级打分
  isFastMark: 0, // 快速打分;0 非快速打分 1快速打分
  summaryMethod: 0, // 汇总方式;0 按个人扣分汇总 1 按项扣分汇总
  fastMarkType: null, // 快速打分类型 0固定 1手动打分
  gradeRelationType: null // 考核项目等级关联类型 0关联项目条数 1关联项目分
});
// 考核查询数据组装
const dynamicValidateForm = ref({
  gradeType: '', // 等级类型 0 关联条数 1关联项目分 2 快速打分-固定 3快速打分-手动
  domains: [
    {
      gradeName: '', // 等级名称;唯一
      gradeScore: '', // 等级分值;有正负
      gradeScoreStart: '', // 等级分值范围开始
      gradeScoreStop: '', // 等级分值范围结束
      relationComputeType: '', // 关联类型 > = <
      gradeScoreComputeType: '',
      relationItemNum: '',
      addCutType: '', // 等级分值 > = <
      key: Date.now()
    }
  ],
  projectPoints: [
    {
      gradeName: '', // 等级名称;唯一
      gradeScore: '', // 等级分值;有正负
      gradeScoreStart: '', // 等级分值范围开始
      gradeScoreStop: '', // 等级分值范围结束
      relationComputeType: '', // 关联类型 > = <
      relationItemNum: '',
      addCutType: '', // 等级分值 > = <
      key: Date.now()
    }
  ],
  fixed: [
    {
      gradeName: '', // 等级名称;唯一
      gradeScore: '', // 等级分值;有正负
      gradeScoreStart: '', // 等级分值范围开始
      gradeScoreStop: '', // 等级分值范围结束
      relationComputeType: '', // 关联类型 > = <
      relationItemNum: '',
      key: Date.now()
    }
  ],
  manual: [
    {
      gradeName: '', // 等级名称;唯一
      gradeScore: '', // 等级分值;有正负
      gradeScoreStart: '', // 等级分值范围开始
      gradeScoreStop: '', // 等级分值范围结束
      relationComputeType: '', // 关联类型 > = <
      gradeScoreStartComputeType: '',
      gradeScoreStopComputeType: '',
      relationItemNum: '',
      key: Date.now(),
      lightColor: '',
      rangeStart: '',
      rangeStop: '',
      id: ''
    }
  ]
});
// 重置数据
const resetFormData = () => {
  dynamicValidateForm.value = {
    gradeType: '', // 等级类型 0 关联条数 1关联项目分 2 快速打分-固定 3快速打分-手动
    domains: [
      {
        gradeName: '', // 等级名称;唯一
        gradeScore: '', // 等级分值;有正负
        gradeScoreStart: '', // 等级分值范围开始
        gradeScoreStop: '', // 等级分值范围结束
        relationComputeType: '', // 关联类型 > = <
        gradeScoreComputeType: '',
        relationItemNum: '',
        addCutType: '', // 等级分值 > = <
        key: Date.now()
      }
    ],
    projectPoints: [
      {
        gradeName: '', // 等级名称;唯一
        gradeScore: '', // 等级分值;有正负
        gradeScoreStart: '', // 等级分值范围开始
        gradeScoreStop: '', // 等级分值范围结束
        relationComputeType: '', // 关联类型 > = <
        relationItemNum: '',
        addCutType: '', // 等级分值 > = <
        key: Date.now()
      }
    ],
    fixed: [
      {
        gradeName: '', // 等级名称;唯一
        gradeScore: '', // 等级分值;有正负
        gradeScoreStart: '', // 等级分值范围开始
        gradeScoreStop: '', // 等级分值范围结束
        relationComputeType: '', // 关联类型 > = <
        relationItemNum: '',
        key: Date.now()
      }
    ],
    manual: [
      {
        gradeName: '', // 等级名称;唯一
        gradeScore: '', // 等级分值;有正负
        gradeScoreStart: '', // 等级分值范围开始
        gradeScoreStop: '', // 等级分值范围结束
        relationComputeType: '', // 关联类型 > = <
        gradeScoreStartComputeType: '',
        gradeScoreStopComputeType: '',
        relationItemNum: '',
        key: Date.now()
      }
    ]
  };
  checkSetting.visible = false;
  list.value = [];
};

/* 打分模式 */
// 关联项目数/关联项目分
const gradeRelationType = ref('1');

// 获取考核相关设置(首次进入考核设置)
const getExamine = () => {
  getExamineSetting().then(res => {
    if (res.data.code === 200) {
      examineSetting.value = res.data.data;
      if (examineSetting.value?.gradeList[0].gradeName !== '') {
        examineSetting.value.gradeList.forEach(item => {
          // list.value.push(item);
          // console.log(item, 'item,item');
        });
      }

      examineSetting.value.summaryMethod = examineSetting.value.summaryMethod
        ? examineSetting.value.summaryMethod
        : 0;
      if (res.data.data.gradeRelationType === 0) {
        gradeRelationType.value = '1';
        dynamicValidateForm.value.domains = [];
        res.data.data.gradeList.forEach((item, index) => {
          dynamicValidateForm.value.domains.push(getNode(item, index));
        });
      } else if (res.data.data.gradeRelationType === 1) {
        gradeRelationType.value = '2';
        dynamicValidateForm.value.projectPoints = [];
        res.data.data.gradeList.forEach((item, index) => {
          dynamicValidateForm.value.projectPoints.push(getNodeType(item, index));
          // list.value.push(dynamicValidateForm.value.projectPoints);
        });
        dynamicValidateForm.value.projectPoints.forEach(item => {
          list.value.push(item);
          console.log(list.value, '++++++++++');
        });
      }
    }
    console.log(dynamicValidateForm.value, 'dynamicValidateForm.value.domains');
  });
};
// 组装关联项目数/关联项目分数据
const getNode = (item, index) => {
  let childrenNode = {
    gradeName: item.gradeName, // 等级名称;唯一
    gradeScore: item.gradeScore, // 等级分值;有正负
    gradeScoreStart: item.gradeScoreStart, // 等级分值范围开始
    gradeScoreStop: item.gradeScoreStop, // 等级分值范围结束
    relationComputeType: item.relationComputeType, // 关联类型 > = <
    relationItemNum: item.relationItemNum,
    gradeScoreComputeType: item.gradeScoreComputeType,
    addCutType: item.addCutType, // 等级分值 > = <
    key: Date.now()
  };
  return childrenNode;
};
const getNodeType = (item, index) => {
  let childrenNode = {
    gradeName: item.gradeName, // 等级名称;唯一
    gradeScore: item.gradeScore, // 等级分值;有正负
    gradeScoreStart: item.gradeScoreStart, // 等级分值范围开始
    gradeScoreStop: item.gradeScoreStop, // 等级分值范围结束
    relationComputeType: item.relationComputeType, // 关联类型 > = <
    relationItemNum: item.relationItemNum,
    gradeScoreComputeType: item.gradeScoreComputeType ? item.gradeScoreComputeType : '+',
    gradeScoreStartComputeType: item.gradeScoreStartComputeType
      ? item.gradeScoreStartComputeType
      : '+',
    gradeScoreStopComputeType: item.gradeScoreStopComputeType,
    addCutType: item.addCutType, // 等级分值 > = <
    key: Date.now()
  };
  return childrenNode;
};
// 设置打分模式
const setMarkModelAPI = () => {
  let obj = {};
  console.log(examineSetting.value.markModel, 'examineSetting.value.markModel');
  console.log(gradeRelationType.value, 'gradeRelationType.value');
  if (examineSetting.value.markModel === 0) {
    obj.markModel = 0;
  } else if (examineSetting.value.markModel === 1) {
    obj.markModel = 1;
    let formDataObj = {};
    let formDataArr = [];
    if (gradeRelationType.value === '1') {
      try {
        dynamicValidateForm.value.domains.forEach((elem, index) => {
          if (!elem.gradeName) {
            message.error(`请输入第${index + 1}条等级名称`);
            throw new Error();
          }
          if (elem.gradeScore === '') {
            message.error(`第${index + 1}条等级分值不能为空`);
            throw new Error();
          }
          if (!elem.relationComputeType) {
            message.error(`请输入第${index + 1}条关联考核项目范围`);
            throw new Error();
          }
          if (elem.relationItemNum === '') {
            message.error(`第${index + 1}条关联考核项目条数不能为空`);
            throw new Error();
          }
        });
      } catch (error) {
        return false;
      }
      let gradeNameList = dynamicValidateForm.value.domains.map(v => v.gradeName);
      let newGradeNameList = [...new Set(gradeNameList)];
      if (gradeNameList.length !== newGradeNameList.length) {
        message.error('等级名称不能重复');
        return false;
      }
      dynamicValidateForm.value.domains.forEach(elem => {
        if (elem.gradeScoreComputeType === '-') elem.gradeScore = -elem.gradeScore;
        formDataObj = {
          gradeName: elem.gradeName,
          gradeScore: elem.gradeScore,
          relationComputeType: elem.relationComputeType,
          relationItemNum: elem.relationItemNum
        };
        formDataArr.push(formDataObj);
      });
      console.log(dynamicValidateForm.value.domains, 'dynamicValidateForm.value.domains');

      // 关联项目条数
      obj.relationItemType = 0;
      obj.relationStripList = formDataArr;
    } else {
      try {
        console.log(
          dynamicValidateForm.value.projectPoints,
          'dynamicValidateForm.value.projectPoints'
        );
        dynamicValidateForm.value.projectPoints.forEach((elem, index) => {
          if (!elem.gradeName) {
            message.error(`请输入第${index + 1}条等级名称`);
            throw new Error();
          }
          if (elem.gradeScoreStart === '') {
            message.error(`第${index + 1}条左侧分值不能为空`);
            throw new Error();
          }
          if (!elem.gradeScoreStartComputeType) {
            message.error(`请输入第${index + 1}条左侧分值符号`);
            throw new Error();
          }
          if (elem.gradeScoreStop === '') {
            message.error(`第${index + 1}条右侧分值不能为空`);
            throw new Error();
          }
          if (!elem.gradeScoreStopComputeType) {
            message.error(`第${index + 1}条右侧分值符号`);
            throw new Error();
          }
          let gradeScoreStart = null;
          let gradeScoreStop = null;
          if (elem.gradeScoreStartComputeType === '-') {
            gradeScoreStart = -elem.gradeScoreStart;
          } else {
            gradeScoreStart = elem.gradeScoreStart;
          }
          if (elem.gradeScoreStopComputeType === '-') {
            gradeScoreStop = -elem.gradeScoreStop;
          } else {
            gradeScoreStop = elem.gradeScoreStop;
          }
          if (
            Number(gradeScoreStart) > Number(gradeScoreStop) ||
            Number(gradeScoreStart) === Number(gradeScoreStop)
          ) {
            message.error(`第${index + 1}条左侧分值不能大于等于右侧分值`);
            throw new Error();
          }
          formDataObj = {
            gradeName: elem.gradeName,
            gradeScoreStart: gradeScoreStart,
            gradeScoreStop: gradeScoreStop
          };
          formDataArr.push(formDataObj);
        });
      } catch (error) {
        return false;
      }
      let gradeNameList = dynamicValidateForm.value.projectPoints.map(v => v.gradeName);
      let newGradeNameList = [...new Set(gradeNameList)];
      if (gradeNameList.length !== newGradeNameList.length) {
        message.error('等级名称不能重复');
        return false;
      }
      // 关联项目分
      obj.relationItemType = 1;
      obj.relationScoreList = formDataArr;
    }
  }
  setMarkModel(obj).then(res => {
    if (res.data.code === 200) {
      message.success(res.data.msg);
      resetFormData();
    } else {
      message.error(res.data.msg);
    }
  });
};

/* 快速打分 */
// 获取考核等级详情
const getExamineGrade = () => {
  getExamineGradeDetail({ isFastMark: true }).then(res => {
    console.log('啥玩意-----', res);
    if (res.data.code === 200) {
      if (res.data.data) {
        dynamicValidateForm.value.gradeType = res.data.data.gradeType;
        if (res.data.data.gradeType === 2) {
          onScoreg.value = true;
          dynamicValidateForm.value.fixed = [];
          res.data.data.gradeList.forEach((item, index) => {
            dynamicValidateForm.value.fixed.push(getNode(item, index));
          });
        } else if (res.data.data.gradeType === 3) {
          onScores.value = true;
          dynamicValidateForm.value.manual = [];
          res.data.data.gradeList.forEach((item, index) => {
            dynamicValidateForm.value.manual.push(getNodeType(item, index));
          });
        } else {
          onScoreg.value = true;
        }
      }
    } else {
      message.error(res.data.msg);
    }
  });
};
// 设置快速打分
const setFastMarkAPI = () => {
  console.log('examineSetting', examineSetting.value.isFastMark);
  if (examineSetting.value.isFastMark === 0) {
    // 关闭快速打分
    closeFastMark().then(res => {
      if (res.data.code === 200) {
        message.success(res.data.msg);
      } else {
        message.error(res.data.msg);
      }
    });
  } else {
    let obj = {};
    if (!dynamicValidateForm.value.gradeType) {
      message.error('请选择固定的分值或手动打分');
      return false;
    }
    console.log(dynamicValidateForm.value);

    let formDataObj = {};
    let formDataArr = [];
    if (dynamicValidateForm.value.gradeType === 2) {
      console.log(dynamicValidateForm.value.fixed);
      let gradeNameList = dynamicValidateForm.value.fixed.map(v => v.gradeName);
      let newGradeNameList = [...new Set(gradeNameList)];
      if (gradeNameList.length !== newGradeNameList.length) {
        message.error('等级名称不能重复');
        return false;
      }
      obj.fastMarkType = 0;
      let scoreCopy = [];
      try {
        dynamicValidateForm.value.fixed.forEach((elem, index) => {
          if (!elem.gradeName) {
            message.error(`请输入第${index + 1}条等级名称`);
            throw new Error();
          }
          if (elem.gradeScore === '') {
            message.error(`第${index + 1}条等级分值不能为空`);
            throw new Error();
          }
          if (!elem.gradeScoreComputeType) {
            message.error(`请输入第${index + 1}条关联考核项目范围`);
            throw new Error();
          }

          if (elem.gradeScoreComputeType === '-') scoreCopy.push(-elem.gradeScore);
          if (elem.gradeScoreComputeType === '+') scoreCopy.push(elem.gradeScore);
          // scoreCopy.push(score);
        });
      } catch (error) {
        return false;
      }
      let newScore = [...new Set(scoreCopy)];
      if (newScore.length !== scoreCopy.length) {
        message.error('等级分值不能重复');
        return false;
      }
      dynamicValidateForm.value.fixed.forEach(v => {
        if (v.gradeScoreComputeType === '-') v.gradeScore = -v.gradeScore;
        formDataArr.push({
          gradeName: v.gradeName,
          gradeScore: v.gradeScore
        });
      });
      // 固定分值
      obj.gradeList = formDataArr;
    } else if (dynamicValidateForm.value.gradeType === 3) {
      obj.fastMarkType = 1;
      try {
        dynamicValidateForm.value.manual.forEach((elem, index) => {
          if (!elem.gradeName) {
            message.error(`请输入第${index + 1}条等级名称`);
            throw new Error();
          }
          if (elem.gradeScoreStart === '') {
            message.error(`第${index + 1}条左侧分值不能为空`);
            throw new Error();
          }
          if (!elem.gradeScoreStartComputeType) {
            message.error(`请输入第${index + 1}条左侧分值符号`);
            throw new Error();
          }
          if (elem.gradeScoreStop === '') {
            message.error(`第${index + 1}条右侧分值不能为空`);
            throw new Error();
          }
          if (!elem.gradeScoreStopComputeType) {
            message.error(`第${index + 1}条右侧分值符号`);
            throw new Error();
          }
          let gradeScoreStart = null;
          let gradeScoreStop = null;
          if (elem.gradeScoreStartComputeType === '-') {
            gradeScoreStart = -elem.gradeScoreStart;
          } else {
            gradeScoreStart = elem.gradeScoreStart;
          }
          if (elem.gradeScoreStopComputeType === '-') {
            gradeScoreStop = -elem.gradeScoreStop;
          } else {
            gradeScoreStop = elem.gradeScoreStop;
          }
          if (
            Number(gradeScoreStart) > Number(gradeScoreStop) ||
            Number(gradeScoreStart) === Number(gradeScoreStop)
          ) {
            message.error(`第${index + 1}条左侧分值不能大于等于右侧分值`);
            throw new Error();
          }
          formDataObj = {
            gradeName: elem.gradeName,
            gradeScoreStart: gradeScoreStart,
            gradeScoreStop: gradeScoreStop
          };
          formDataArr.push(formDataObj);
        });
      } catch (error) {
        return false;
      }
      let gradeNameList = dynamicValidateForm.value.manual.map(v => v.gradeName);
      let newGradeNameList = [...new Set(gradeNameList)];
      if (gradeNameList.length !== newGradeNameList.length) {
        message.error('等级名称不能重复');
        return false;
      }
      // 手动打分
      obj.gradeList = formDataArr;
    }
    console.log(obj);
    setFastMark(obj).then(res => {
      if (res.data.code === 200) {
        message.success(res.data.msg);
        resetFormData();
      } else {
        message.error(res.data.msg);
      }
    });
  }
};
// 亮灯分数输入的时候设置

const changLanpInput = value => {
  console.log('数组', dynamicValidateForm.value.manual);
  console.log('输入的分数是什么', value.data);
  // dynamicValidateForm.value.manual.forEach((ele, index) => {
  //   if (value.data > ele.leftFraction && value.data < ele.rightFraction) {
  //     message.error(`第${index + 1}条取值范围重复`);
  //   }
  // });
};
// 保存亮灯时间
const SaveLightSettingAndType = () => {
  if (!settingLampTimeNew.value.startTime) {
    message.error('请选择亮灯开始时间');
    return false;
  }
  if (!settingLampTimeNew.value.stopTime) {
    message.error('请选择亮灯结束时间');
    return false;
  }

  if (
    time_to_sec(settingLampTimeNew.value.startTime) -
      time_to_sec(settingLampTimeNew.value.stopTime) >
    0
  ) {
    message.error('结束时间必须晚于开始时间');
    return false;
  }
  if (
    time_to_sec(settingLampTimeNew.value.startTime) -
      time_to_sec(settingLampTimeNew.value.stopTime) ===
    0
  ) {
    message.error('结束时间不能等于开始时间');
    return false;
  }
  let formDataObjLamp = {};
  let formDataArrLamp = [];
  try {
    dynamicValidateForm.value.manual.forEach((elem, index) => {
      if (!elem.lightColor) {
        message.error(`请选择第${index + 1}条颜色值`);
        throw new Error();
      }
      if (!elem.rangeStop) {
        message.error(`第${index + 1}条左侧分数不能为空`);
        throw new Error();
      }
      if (!elem.rangeStart) {
        message.error(`第${index + 1}条右侧分数不能为空`);
        throw new Error();
      }

      formDataObjLamp = {
        lightColor: elem.lightColor,
        rangeStart: elem.rangeStart,
        rangeStop: elem.rangeStop
      };
      formDataArrLamp.push(formDataObjLamp);
    });
  } catch (error) {
    return false;
  }
  let obj = {
    startTime: settingLampTimeNew.value.startTime,
    stopTime: settingLampTimeNew.value.stopTime,
    lightTypeBoList: formDataArrLamp
  };
  console.log('保存亮灯配置-入参', obj);
  saveLightSettingAndType(obj).then(res => {
    if (res.data.code === 200) {
      console.log('亮灯设置保存', res);
      message.success(res.data.msg);
    } else {
      message.error(res.data.msg);
    }
  });
};
// 回显亮灯时间
const GetLightSetting = () => {
  getLightSetting().then(res => {
    if (res.data.code === 200) {
      console.log('回显亮灯时间', res);
      if (res.data.data && res.data.data.startTime) {
        settingLampTime.value.startTime = ref(dayjs(res.data.data.startTime, 'HH:mm:ss'));
        settingLampTimeNew.value.startTime = res.data.data.startTime;
      }
      if (res.data.data && res.data.data.stopTime) {
        settingLampTime.value.stopTime = ref(dayjs(res.data.data.stopTime, 'HH:mm:ss'));
        settingLampTimeNew.value.stopTime = res.data.data.stopTime;
      }
    } else {
      message.error(res.data.msg);
    }
  });
};

// 回显亮灯规则
const ListLightType = () => {
  listLightType().then(res => {
    if (res.data.code === 200) {
      console.log('回显亮灯规则', res);
      if (res.data.data) {
        dynamicValidateForm.value.manual = [];
        res.data.data.forEach((item, index) => {
          dynamicValidateForm.value.manual.push(item);
        });
      }
    } else {
      message.error(res.data.msg);
    }
  });
};
// 设置快速打分-- 最外层
const setFastMarkAPINew = () => {
  if (!settingLampTime.value.startTime) {
    message.error('请选择亮灯开始时间');
    return false;
  }
  if (!settingLampTime.value.stopTime) {
    message.error('请选择亮灯结束时间');
    return false;
  }
  // 保存时间设置
  SaveLightSettingAndType();
  console.log('examineSetting', examineSetting.value.isFastMark);
  let obj = {};
  let formDataObj = {};
  let formDataArr = [];

  let objLamp = {};
  let formDataObjLamp = {};
  let formDataArrLamp = [];

  obj.fastMarkType = 1;
  try {
    dynamicValidateForm.value.manual.forEach((elem, index) => {
      if (!elem.gradeName) {
        message.error(`请输入第${index + 1}条等级名称`);
        throw new Error();
      }
      if (elem.gradeScoreStart === '') {
        message.error(`第${index + 1}条左侧分值不能为空`);
        throw new Error();
      }
      if (!elem.gradeScoreStartComputeType) {
        message.error(`请输入第${index + 1}条左侧分值符号`);
        throw new Error();
      }
      if (elem.gradeScoreStop === '') {
        message.error(`第${index + 1}条右侧分值不能为空`);
        throw new Error();
      }
      if (!elem.gradeScoreStopComputeType) {
        message.error(`第${index + 1}条右侧分值符号`);
        throw new Error();
      }
      //
      // if (!elem.color) {
      //   message.error(`请选择第${index + 1}条颜色值`);
      //   throw new Error();
      // }
      // if (!elem.leftFraction) {
      //   message.error(`第${index + 1}条左侧分数不能为空`);
      //   throw new Error();
      // }
      // if (!elem.rightFraction) {
      //   message.error(`第${index + 1}条左侧分数不能为空`);
      //   throw new Error();
      // }
      if (elem.rightFraction < elem.leftFraction) {
        message.error(`第${index + 1}条左侧分数不能大于右侧分数`);
      }
      if (elem.rightFraction === elem.leftFraction) {
        message.error(`第${index + 1}条两侧分数不能相同`);
      }
      //
      let gradeScoreStart = null;
      let gradeScoreStop = null;
      if (elem.gradeScoreStartComputeType === '-') {
        gradeScoreStart = -elem.gradeScoreStart;
      } else {
        gradeScoreStart = elem.gradeScoreStart;
      }
      if (elem.gradeScoreStopComputeType === '-') {
        gradeScoreStop = -elem.gradeScoreStop;
      } else {
        gradeScoreStop = elem.gradeScoreStop;
      }
      if (
        Number(gradeScoreStart) > Number(gradeScoreStop) ||
        Number(gradeScoreStart) === Number(gradeScoreStop)
      ) {
        message.error(`第${index + 1}条左侧分值不能大于等于右侧分值`);
        throw new Error();
      }
      formDataObj = {
        gradeName: elem.gradeName,
        gradeScoreStart: gradeScoreStart,
        gradeScoreStop: gradeScoreStop
      };
      formDataArr.push(formDataObj);

      formDataObjLamp = {
        time: settingLampTime.value.time,
        color: elem.color,
        leftFraction: elem.leftFraction,
        rightFraction: elem.rightFraction
      };
      formDataArrLamp.push(formDataObjLamp);
    });
  } catch (error) {
    return false;
  }
  let gradeNameList = dynamicValidateForm.value.manual.map(v => v.gradeName);
  let newGradeNameList = [...new Set(gradeNameList)];
  if (gradeNameList.length !== newGradeNameList.length) {
    message.error('等级名称不能重复');
    return false;
  }
  // 手动打分
  obj.gradeList = formDataArr;

  console.log(obj);
  console.log('保存的入参是什么', obj);
  console.log('保存的入参是什么Lamp', formDataArrLamp);
  setFastMark(obj).then(res => {
    if (res.data.code === 200) {
      message.success(res.data.msg);
      // resetFormData();
      getExamineGrade();
    } else {
      message.error(res.data.msg);
    }
  });
};
/* 其他 */
// 设置个人项目扣分汇总方式
const summarySet = () => {
  summarySetting({ summaryMethod: examineSetting.value.summaryMethod }).then(res => {
    if (res.data.code === 200) {
      message.success(res.data.msg);
      resetFormData();
    } else {
      message.error(res.data.msg);
    }
  });
};
</script>

<style lang="less" scoped>
.red {
  color: red;
}
.tips {
  position: absolute;
  right: 25px;
  top: 200px;
}
.top11,
.below11 {
  // min-width: 1152px;
  width: 100%;
  // width: 130%;
  // flex: 1;
  padding: 24px;
  background: #ffffff;
  border-radius: 4px;
}

.below11 {
  .search {
    display: flex;
    justify-content: space-between;
    .search-btn-left {
      width: 40%;
      display: flex;
      justify-content: flex-start;
      margin-bottom: 24px;
      a-button {
        margin-left: 16px;
      }
    }
    .search-btn-right {
      width: 40%;
      display: flex;
      justify-content: flex-end;
    }
  }
}
.tree-content {
  height: 800px;
  overflow-y: auto;
}
.tree-content::-webkit-scrollbar {
  width: 6px;
}
/*滚动条里面小方块样式*/
.tree-content::-webkit-scrollbar-thumb {
  background: rgba(20, 20, 20, 0.01);
  border-radius: 3px;
  height: 3px;
}
/*滚动条里面轨道样式*/
.tree-content::-webkit-scrollbar-track {
  background: transparent;
}
.top11 {
  margin-bottom: 24px;
  .search {
    display: flex;
    justify-content: flex-end;
  }
}
.pagination {
  align-items: center;
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}
.checkOutStyle {
  width: 280px;
  height: 48px;
  background: #f8f8f8;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 14px;
  img {
    margin-right: 8px;
  }
}
.checkOut-notes {
  padding: 14px;
  font-size: 12px;
  font-family: Source Han Sans CN, Source Han Sans CN-Regular;
  font-weight: 400;
  color: #999999;
}
.campus {
  width: 64px;
  height: 24px;
  font-size: 16px;
  font-family: Source Han Sans CN, Source Han Sans CN-Regular;
  font-weight: 400;
  text-align: LEFT;
  color: #222222;
  line-height: 24px;
  margin-bottom: 16px;
}
.content {
  display: flex;
  justify-content: space-between;
  .option {
    width: 208px;
    border: 1px solid #e1dddd;
    border-radius: 4px;
  }
  .details {
    width: 609px;
    border: 1px solid #e1dddd;
    border-radius: 4px;
    .info {
      height: 46px;
      font-size: 16px;
      line-height: 46px;
      font-family: Source Han Sans CN, Source Han Sans CN-Regular;
      font-weight: 400;
      color: #222222;
      border-bottom: 1px solid #e1dddd;
      padding-left: 16px;
    }
    .info-content {
      height: 32px;
      display: flex;
      align-items: center;
      padding: 24px 24px;
    }
  }
}
.week-content-add {
  width: 657px;
  height: 56px;
  margin: 16px 24px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f8f8;
  border-radius: 4px;
  span {
    font-size: 16px;
    font-family: Source Han Sans CN, Source Han Sans CN-Regular;
    font-weight: 400;
    color: #999999;
  }
  img {
    width: 24px;
    height: 24px;
  }
}
.micro-dormitoryt-form-item {
  margin-bottom: 0 !important;
}

/deep/.micro-dormitory-tabs-nav {
  padding: 0 10px !important;
}
// .micro-dormitory-tabs-tabpane {
//   margin-left: 10px !important;
// }
/deep/.micro-dormitory-collapse-content-box {
  padding: 16px 0 16px 16px !important;
}
/deep/.micro-dormitory-tree-treenode {
  width: 100%;
  // width: 1350px;
  height: 60px;
  border: 1px solid #eeeeee;
  color: #666666;
}
.arow {
  display: flex;
  justify-content: space-between;
  line-height: 13px;
  color: black;
  // width: 1350px;
}

/deep/.micro-dormitory-tree-node-selected {
  background: #ffffff !important;
}

/deep/.micro-dormitory-tree-node-content-wrapper:hover {
  background: #ffffff !important;
}
/deep/.micro-dormitory-tree-switcher {
  line-height: 58px !important;
}
/deep/.micro-dormitory-select-tree-switcher-icon {
  color: #c2c2c2;
}
// /deep/.micro-dormitory-tree-list-holder-inner {
//   align-items: stretch !important;
// }
/deep/.micro-dormitory-tree-treenode.micro-dormitory-tree-treenode-switcher-open.micro-dormitory-tree-treenode-selected {
  width: 100%;
}
/deep/.micro-dormitory-col-sm-offset-4 {
  margin-left: 0px !important;
}

.dynamic-delete-button {
  cursor: pointer;
  position: relative;
  top: 4px;
  font-size: 24px;
  color: #999;
  transition: all 0.3s;
}
.dynamic-delete-button:hover {
  color: #777;
}
.dynamic-delete-button[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}
/deep/.micro-dormitory-tree-treenode {
  position: static !important;
}
/deep/.micro-dormitory-tree-node-content-wrapper,
/deep/.micro-dormitory-tree-node-content-wrapper-close {
  width: 100% !important;
}

/deep/.anticon-file {
  display: none;
}
/deep/.micro-dormitory-tree.micro-dormitory-tree-directory .micro-dormitory-tree-treenode::before {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 10px;
  left: 100%;
  transition: black 0.1s;
  content: '';
  pointer-events: auto;
}
/deep/.micro-dormitory-tree-node-content-wrapper.micro-dormitory-tree-node-content-wrapper-close {
  .anticon-folder {
    display: none;
  }
}

/deep/.micro-dormitory-tree-node-content-wrapper.micro-dormitory-tree-node-content-wrapper-open {
  .anticon-folder-open {
    display: none;
  }
}

/deep/.micro-dormitory-tree.micro-dormitory-tree-directory
  .micro-dormitory-tree-treenode-selected
  .micro-dormitory-tree-switcher {
  color: #222222;
}
/*定义滚动条样式*/
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  background-color: rgba(240, 240, 240, 1);
}
/*定义滚动条轨道内阴影+圆角*/
::-webkit-scrollbar-track {
  box-shadow: inset000pxrgba(240, 240, 240, 0.5);
  border-radius: 10px;
  background-color: rgba(240, 240, 240, 0.5);
} /*定义滑块内阴影+圆角*/
::-webkit-scrollbar-thumb {
  border-radius: 10px;
  box-shadow: inset000pxrgba(240, 240, 240, 0.5);
  background-color: rgba(240, 240, 240, 0.5);
}
.required-tips::before {
  float: left;

  content: '*';
  line-height: 2rem;
  color: #ff0000;
}
.required-tip::before {
  content: '*';
  color: #ff0000;
  position: absolute;
  /* bottom: 20px; */
  line-height: 2rem;
  left: 50px;
}

/deep/.micro-dormitory-select-arrow {
  top: 40%;
}
// /deep/.micro-dormitory-picker-content .micro-dormitory-picker-time-panel-column:nth-child(3) {
//   display: none;
// }
.line-z {
  display: flex;
  align-items: center;
}
.text-center {
  text-align: center;
}
</style>
